<?php namespace Admin\Controller; 


use Admin\Model\Shoptype;

//测试控制器
class ShoptypeController extends AuthController{

	protected $db;
	//构造函数
	public function __init()
	{
		$this->db = new Shoptype;
	}
	
    //商品类型列表
    public function index(){
    	$data = $this->db ->getAll();
      	View::with('data',$data)->make();
    }
	
	//添加类型
	public function add()
	{
		if(IS_POST){
			if($this->db->store()){
				View::success('添加成功','index');
			}else{
				View::error($this->db->getError());
			}
		}else{
			View::make();
		}
		
	}
	
	//修改类型
	public function edit()
	{
		if(IS_POST){
			if($this->db->edit()){
				View::success('添加成功','index');
			}else{
				View::error($this->db->getError());
			}
		}else{
			$file = $this->db->one($_GET['id']);
//			p($file);die;
			View::with('file',$file)->make();
		}
		
	}
	
}
